package com.gitee.hljdrl.ffkit.util;

import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;

import java.util.Random;

public class FFKitUtil {

    public static Drawable getRandomColorDrawable() {
        Random random = new Random();
        int mStartColor = 0xff000000 | random.nextInt(0xffffff);
        ColorDrawable drawable = new ColorDrawable(mStartColor);
        return drawable;
    }

    public static Drawable getRandomGradientDrawable() {
        Random random = new Random();
        int mStartColor = 0xff000000 | random.nextInt(0xffffff);
        int mEndColor = 0xff000000 | random.nextInt(0xffffff);
        int[] colors = {mStartColor, mEndColor};
        GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, colors);
        return gradientDrawable;
    }

    public static int getRandomInt(int min, int max) {
        if (min == 0 && max == 0) {
            return 0;
        }
        return min + (int) (Math.random() * (max - min + 1));
    }

    public static String string(String... str) {
        StringBuffer buffer = new StringBuffer();
        if (str != null) {
            for (String _s : str) {
                buffer.append(_s);
            }
        }
        return buffer.toString();
    }

    public static String string(Object... str) {
        StringBuffer buffer = new StringBuffer();
        if (str != null) {
            for (Object _s : str) {
                if (_s != null) {
                    buffer.append(_s);
                }
            }
        }
        return buffer.toString();
    }
}
